/*     */ package com.zimbra.cs.dav.property;
/*     */ 
/*     */ import com.zimbra.common.util.HttpUtil;
/*     */ import com.zimbra.cs.dav.DavContext;
/*     */ import com.zimbra.cs.dav.DavElements;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import java.util.Locale;
/*     */ import org.dom4j.DocumentHelper;
/*     */ import org.dom4j.Element;
/*     */ import org.dom4j.QName;
/*     */ import org.dom4j.tree.DefaultElement;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ResourceProperty
/*     */ {
/*     */   private boolean mProtected;
/*     */   private boolean mVisible;
/*     */   private boolean mLive;
/*     */   private QName mName;
/*     */   private Locale mLocale;
/*     */   private String mValue;
/*     */   protected ArrayList<Element> mChildren;
/*     */   private boolean allowSetOnCreate;
/*     */   
/*     */   public ResourceProperty(String name)
/*     */   {
/*  49 */     this(QName.get(name, DavElements.WEBDAV_NS));
/*     */   }
/*     */   
/*     */   public ResourceProperty(QName name) {
/*  53 */     this.mName = name;
/*  54 */     this.mChildren = new ArrayList();
/*     */   }
/*     */   
/*     */   public ResourceProperty(Element elem) {
/*  58 */     this(elem.getQName());
/*  59 */     this.mValue = elem.getText();
/*  60 */     for (Object o : elem.elements()) {
/*  61 */       if ((o instanceof Element))
/*  62 */         this.mChildren.add((Element)o);
/*     */     }
/*     */   }
/*     */   
/*     */   public QName getName() {
/*  67 */     return this.mName;
/*     */   }
/*     */   
/*     */   public boolean isProtected()
/*     */   {
/*  72 */     return this.mProtected;
/*     */   }
/*     */   
/*     */   public boolean isAllowSetOnCreate() {
/*  76 */     return this.allowSetOnCreate;
/*     */   }
/*     */   
/*     */   public boolean isVisible()
/*     */   {
/*  81 */     return this.mVisible;
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean isLive()
/*     */   {
/*  87 */     return this.mLive;
/*     */   }
/*     */   
/*     */   public Element toElement(DavContext ctxt, Element parent, boolean nameOnly)
/*     */   {
/*  92 */     Element elem = parent.addElement(this.mName);
/*  93 */     if (nameOnly) {
/*  94 */       return elem;
/*     */     }
/*  96 */     if (this.mValue != null) {
/*  97 */       if (this.mLocale != null)
/*  98 */         elem.addAttribute(DavElements.E_LANG, this.mLocale.toString());
/*  99 */       elem.setText(this.mValue);
/*     */     } else {
/* 101 */       for (Element child : this.mChildren)
/* 102 */         elem.add(child.createCopy()); }
/* 103 */     return elem;
/*     */   }
/*     */   
/*     */   public void setMessageLocale(Locale locale)
/*     */   {
/* 108 */     this.mLocale = locale;
/*     */   }
/*     */   
/*     */   public void setStringValue(String value)
/*     */   {
/* 113 */     this.mValue = value;
/*     */   }
/*     */   
/*     */   public String getStringValue()
/*     */   {
/* 118 */     return this.mValue;
/*     */   }
/*     */   
/*     */   public Element addChild(QName e)
/*     */   {
/* 123 */     Element child = new DefaultElement(e);
/* 124 */     this.mChildren.add(child);
/* 125 */     return child;
/*     */   }
/*     */   
/*     */   public List<Element> getChildren()
/*     */   {
/* 130 */     return this.mChildren;
/*     */   }
/*     */   
/*     */   public void setProtected(boolean pr) {
/* 134 */     this.mProtected = pr;
/* 135 */     this.mVisible = (!pr);
/*     */   }
/*     */   
/*     */   public void setAllowSetOnCreate(boolean set) {
/* 139 */     this.allowSetOnCreate = set;
/*     */   }
/*     */   
/*     */   public void setVisible(boolean v) {
/* 143 */     this.mVisible = v;
/*     */   }
/*     */   
/*     */   protected Element createHref(String path) {
/* 147 */     Element e = DocumentHelper.createElement(DavElements.E_HREF);
/* 148 */     e.setText(HttpUtil.urlEscape(path));
/* 149 */     return e;
/*     */   }
/*     */   
/*     */   public String toString() {
/* 153 */     return "ResourceProperty: " + this.mName + (this.mValue != null ? ": '" + this.mValue + "'" : "");
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/property/ResourceProperty.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */